home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / network / exp16116.zip / EXP16.ASM < prev    next >
Assembly Source File  |  1994-05-20  |  64KB  |  2,958 lines

  1. version        equ    6
  2. DEBUG        equ    0
  3. ;History:1985,1
  4.  
  5. ;  Copyright 1991, 1992, 1993 Russell Nelson
  6.  
  7. ;   This program is free software; you can redistribute it and/or modify
  8. ;   it under the terms of the GNU General Public License as published by
  9. ;   the Free Software Foundation, version 1.
  10. ;
  11. ;   This program is distributed in the hope that it will be useful,
  12. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;   GNU General Public License for more details.
  15. ;
  16. ;   You should have received a copy of the GNU General Public License
  17. ;   along with this program; if not, write to the Free Software
  18. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.     include    defs.asm
  21.  
  22. code    segment    word public
  23.     assume    cs:code, ds:code
  24.  
  25. ;
  26. ;    Waits for SCB command unit to become idle
  27. ;
  28. ;    MUST NOT TRASH CX OR THE ISSUE_COMMAND PROCEDURE WILL FAIL
  29. ;cmd_clear exits with cy if the command didn't become idle in one millisecond.
  30.  
  31. cmd_clear    macro
  32.     local    exit
  33.  
  34.     lea    dx, [bp].@SCB_CMD        ;BP -> I/O Base
  35.  
  36.     in    ax, dx                ;Read SCB command
  37.     or    ax, ax                ;Wait for command accepted
  38.     jz    exit
  39.  
  40.     call    cmd_wait
  41. exit:
  42.     endm
  43.  
  44. ;
  45. ; Drives channel attention to the 586.  We don't care whats in AX, the write
  46. ; will cause the ASIC to drive CA to the 586.
  47. ;
  48.     issue_ca    MACRO
  49.     lea    dx, [bp].@CA_Ctrl
  50.     out    dx, al
  51.     endm
  52.  
  53.  
  54. ;
  55. ;
  56. ;  Enable and disable exp16s interrupts.
  57. ;
  58. enable_board_ints    macro
  59.     lea    dx, [bp].@Sel_IRQ
  60.     mov    al, encoded_int_no
  61.     or    al, 08h
  62.     out    dx, al
  63.     endm
  64.  
  65. disable_board_ints    macro
  66.     lea    dx, [bp].@Sel_IRQ
  67.     mov    al, encoded_int_no
  68.     out    dx, al
  69.     endm
  70.  
  71.  
  72. RxBufferSize    equ    1518+14+18    ;Max Rx packet+MAC header+
  73.                         ; 18 (alignment)
  74. TxBufferSize    equ    1518+14+20    ;Max Tx packet+MAC header+
  75.                         ; 20 (alignment)
  76.  
  77.     include    exp16.inc
  78.  
  79. _64K_not_32K    db    0    ;<>0 if we have 64K of memory.
  80. _16_not_8_bit_slot    db    0    ;<>0 if we're in a 16-bit slot.
  81.  
  82. ;possible values for connection_type:
  83. CONN_BNC    equ    0
  84. CONN_AUI    equ    1
  85. CONN_TPE    equ    2
  86. CONN_AUTO    equ    3
  87. connection_type    db    ?
  88.  
  89. ;Memory Sizes
  90. mem_size_address    equ    00H
  91. _32K        equ    00000h
  92. _64K        equ    00001h
  93.  
  94. CONNECTION_ADDRESS    equ    00H
  95. CONNECTION_FIELD    equ    0001000000000000B
  96.  
  97. AUTO_CON_ADDRESS    EQU    01H
  98. AUTO_CON_MASK    EQU    10000000B
  99.  
  100. TPE_address    equ    05H
  101. TPE_type_field    equ    0000000000000001B
  102.  
  103. int_num_address    equ    00H
  104. int_num_field    equ    1110000000000000B
  105. int_field_shift    equ    13
  106.  
  107. EE_ETHERNET_ADD_LOW    equ    2
  108. EE_ETHERNET_ADD_MID    equ    3
  109. EE_ETHERNET_ADD_HIGH    equ    4
  110. EE_INT        equ    0
  111. EE_SHIFT    equ    13
  112.  
  113. ;    Slot Width
  114. slot_width_mask    equ    04h
  115. _16_bit_slot    equ    0000h
  116. _8_bit_slot    equ    0001h
  117.  
  118. _16_bit_override_bit    equ    08h
  119.  
  120.  
  121. ;
  122. ;    EXP16 base port structure
  123. ;
  124. @EXP16BasePorts    struc
  125. @Data_Reg    dw    ?        ;Data Transfer Register.
  126. @Write_Ptr    dw    ?        ;Write Address Pointer.
  127. @Read_Ptr    dw    ?        ;Read Address Pointer.
  128. @CA_Ctrl    db    ?        ;Channel Attention Control.
  129. @Sel_IRQ    db    ?        ;IRQ Select.
  130. @SMB_Ptr    dw    ?        ;Shadow Memory Bank Pointer.
  131.     db    ?
  132. @MEM_Ctrl    db    ?
  133. @MEM_Page_Ctrl    db    ?
  134. @Config        db    ?
  135. @EEPROM_Ctrl    db    ?
  136. @ID_Port    db    ?
  137. @EXP16BasePorts    ends
  138.  
  139. ECR1        equ    300eh
  140.  
  141. @ISR_Ports    struc
  142.     db    0C008h dup(?)
  143. @SCB_STAT    dw    ?
  144. @SCB_CMD    dw    ?
  145. @SCB_CBL    dw    ?
  146. @SCB_RFA    dw    ?
  147. ;        @SCB_CRCERRS    dw      ?
  148. ;        @SCB_ALNERRS    dw      ?
  149. ;        @SCB_RSCERRS    dw      ?
  150. ;        @SCB_OVRNERRS   dw      ?
  151. @ISR_Ports    ends
  152.  
  153.  
  154.     @memory_page_struc    STRUC
  155.     DB    4000H DUP (?)
  156.     @mem_loc_0    DW    ?
  157.     @mem_loc_2    DW    ?
  158.     @mem_loc_4    DW    ?
  159.     @mem_loc_6    DW    ?
  160.     @mem_loc_8    DW    ?
  161.     @mem_loc_10    DW    ?
  162.     @mem_loc_12    DW    ?
  163.     @mem_loc_14    DW    ?
  164.     DB    4000H - 16 DUP (?)
  165.     @mem_loc_16    DW    ?
  166.     @mem_loc_18    DW    ?
  167.     @mem_loc_20    DW    ?
  168.     @mem_loc_22    DW    ?
  169.     @mem_loc_24    DW    ?
  170.     @mem_loc_26    DW    ?
  171.     @mem_loc_28    DW    ?
  172.     @mem_loc_30    DW    ?
  173.     @memory_page_struc    ENDS
  174.  
  175. ;
  176. ;
  177. ;    TData Segment
  178. ;
  179. ;    This segment template represents the 64-KB segment that the 82586
  180. ;    can address.  Shared memory can be either 32K or 64K for the EXP16.
  181. ;    All structures must be quad-word aligned.
  182. ;
  183. ;    Offset    Type of Block    Block Size    Cnt
  184. ;    ------    -------------    ----------    ---
  185. ;    0000h    ISCP        8        1
  186. ;    0008h    SCB        16        1
  187. ;    0020h    CommandBlock    104        1
  188. ;    00E0h    SendBlock(s)    1568        variable
  189. ;    ????h    ReceiveBlock(s)    1568        variable
  190. ;    FFF6h    SCP        10        1
  191. ;
  192.  
  193. TData_64    segment at 0
  194.  
  195.     ISCP    ISysConfigPtr  <>
  196.     SCB    SystemControlBlock <>
  197.  
  198.     ORG    20H
  199.  
  200.     CB    CommandBlock    <>
  201.  
  202.     Send_Blocks    DB    SIZE SendBlock * Number_of_Tx_Buffers dup (?)
  203.     Receive_Blocks    LABEL    WORD
  204.  
  205.  
  206.     ORG    (0FFFFh - SIZE SCPS + 1) AND 0FFE0H
  207.     SCP    LABEL    BYTE
  208.  
  209.     ORG    0FFFFh - SIZE SCPS + 1
  210.     THeapTop    LABEL    BYTE            ;Top of available memory
  211.  
  212. end_of_send_blocks    =    20h + SIZE CommandBlock + (Number_of_Tx_Buffers * SIZE SendBlock)
  213. num_rx_buf_32k    =    (07FFFh - SIZE SCPS + 1 - end_of_send_blocks) / (SIZE ReceiveBlock)
  214. num_rx_buf_64k    =    (0FFFFh - SIZE SCPS + 1 - end_of_send_blocks) / (SIZE ReceiveBlock)
  215.  
  216.     TData_64    ENDS
  217.  
  218.  
  219.     public    int_no
  220. int_no        db    3,0,0,0        ;must be four bytes long for get_number.
  221. io_addr        dw    -1,-1        ; I/O address for card
  222. encoded_int_no    db    ?        ;encoded for exp16.
  223.  
  224.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  225. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  226. driver_type    db    91        ;from the packet spec
  227. driver_name    db    'EtherExpress16',0    ;name of the driver.
  228. driver_function    db    2 + 16 + 8    ;8 = error in DH, 16 = has TDR function.
  229. parameter_list    label    byte
  230.     db    1    ;major rev of packet driver
  231.     db    9    ;minor rev of packet driver
  232.     db    14    ;length of parameter list
  233.     db    EADDR_LEN    ;length of MAC-layer address
  234.     dw    GIANT    ;MTU, including MAC headers
  235.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  236.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  237.     dw    0    ;(# of successive xmits) - 1
  238. int_num        dw    0    ;Interrupt # to hook for post-EOI
  239.             ;processing, 0 == none,
  240. save_err    db    0        ;error bits on promiscuous recieve
  241. pro0        db    0
  242. pro1        db    0
  243.  
  244.     BART_Board_ID    EQU    0BABAH
  245.     BUD_board_ID    EQU    0BABBH
  246.     mca_hp_board_ID    EQU    0BABCH
  247.  
  248. board_id    dw    ?
  249.  
  250.     public    rcv_modes
  251. rcv_modes    dw    7        ;number of receive modes in our table.
  252.     dw    0            ;There is no mode zero
  253.     dw    0
  254.     dw    rcv_mode_2
  255.     dw    rcv_mode_3
  256.     dw    rcv_mode_4    ;haven't set up perfect filtering yet.
  257.     dw    0
  258.     dw    rcv_mode_6
  259.  
  260. ;
  261. ;    82586 Configuration Parameters
  262. ;
  263.     config_params    LABEL    WORD
  264.     num_config_params    LABEL    BYTE    ;12 BYTEs
  265.     DB    0CH
  266.  
  267.     fifo_limit    LABEL    BYTE
  268.     DB    14
  269.  
  270.     srdy    LABEL    BYTE    ;srdy = 1
  271.     save_bad_frame    LABEL    BYTE    ;do not save bad frame
  272.     DB    40H
  273.  
  274.     address_length    LABEL    BYTE    ;6 BYTEs
  275.     auto_insert_address    LABEL    BYTE    ;auto insert off (1)
  276.     preamble_length    LABEL    BYTE    ;2 BYTEs
  277.     internal_loopback    LABEL    BYTE    ;0 = OFF  1 = ON
  278.     external_loopback    LABEL    BYTE    ;0 = OFF  1 = ON
  279.     DB    2EH    ;26h in IPXWS
  280.  
  281.     linear_priority    LABEL    BYTE    ;default is 0
  282.     accel_contention_resolution    LABEL    BYTE    ;default is 0
  283.     exp_backoff_method    LABEL    BYTE    ;0 = 802.3  1 = Alternate
  284.     DB    00H
  285.  
  286.     interframe_spacing    LABEL    BYTE    ;default is 60H (96 bits)
  287.     DB    60H
  288.  
  289.     slot_time_low    LABEL    BYTE    ;0
  290.     DB    00H
  291.  
  292.     slot_time_high    LABEL    BYTE    ;2
  293.     retry_num    LABEL    BYTE    ;15
  294.     DB    0F2H
  295.  
  296.     promiscuous_mode    LABEL    BYTE    ;0 = OFF  1 = ON
  297.     broadcast_disable    LABEL    BYTE    ;0 = OFF  1 = ON
  298.     encode_decode    LABEL    BYTE    ;0 = NRZ  1 = MANCHESTER
  299.     transmit_on_no_carrier    LABEL    BYTE    ;0 = STOP 1 = CONTINUE
  300.     no_crc_insertion    LABEL    BYTE    ;0 = OFF  1 = ON
  301.     crc_type    LABEL    BYTE    ;0 = 32 bit autodin II
  302.                         ;1 = 16 bit CCITT
  303.     bit_stuffing    LABEL    BYTE    ;0 = 802.3  1 = HDLC
  304.     padding    LABEL    BYTE    ;0 = OFF  1 = ON
  305.     DB    00H
  306.  
  307.     carrier_sense_filter    LABEL    BYTE    ;0 = OFF  1 = 0N
  308.     carrier_sense_source    LABEL    BYTE    ;0 = external  1 = internal
  309.     collision_detect_filter    LABEL    BYTE    ;default = 0
  310.     collision_detect_source    LABEL    BYTE    ;0 = external  1 = internal
  311.     DB    00H
  312.  
  313.     min_frame_length    LABEL    BYTE    ;60 BYTEs
  314.     DB    60
  315.     DB    00H    ;undefined
  316.  
  317.  
  318. RxBufferCount    dw    ?
  319. TxBufferCount    dw    ?
  320.  
  321.     Receive_Head    DW    ?
  322.     Receive_Tail    DW    ?
  323.  
  324. HEADER_LEN    equ    EADDR_LEN + EADDR_LEN + MAX_P_LEN
  325.     even
  326. our_type    db    HEADER_LEN dup(?)
  327.  
  328.     extrn    is_186: byte        ;=0 if 808[68], =1 if 80[123]86.
  329.     extrn    sys_features: byte
  330.  
  331.     include    io16.asm
  332.  
  333.     public    bad_command_intercept
  334. bad_command_intercept:
  335. ;called with ah=command, unknown to the skeleton.
  336. ;exit with nc if okay, cy, dh=error if not.
  337.     c